package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemServiceCategoryRightBinding;
import com.sgb.kjwl.model.entity.ParentAreaEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class ServiceCategoryRightAdapter extends BaseRecycleAdapter<ParentAreaEntity<List<ParentAreaEntity>>> {



    public ServiceCategoryRightAdapter(Context context,  List<ParentAreaEntity<List<ParentAreaEntity>>> datas) {
        super(context, R.layout.item_service_category_right, datas);
    }




    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        ImageView imageView = ((ItemServiceCategoryRightBinding) holder.getmBinding()).image;
        RoundedCorners roundedCorners = new RoundedCorners(8);//数字为圆角度数
        RequestOptions coverRequestOptions = new RequestOptions()
                .transforms(new CenterCrop(),roundedCorners)
                .diskCacheStrategy(DiskCacheStrategy.NONE)//不做磁盘缓存
                .skipMemoryCache(true);//不做内存缓存
        Glide.with(context).asBitmap().load(datas.get(position).getImageurl()).apply(coverRequestOptions).into(imageView);
        TextView tvcontent =((ItemServiceCategoryRightBinding) holder.getmBinding()).tvContent;
        tvcontent.setText(datas.get(position).getName());

    }

    @Override
    public void convert(ItemViewHolder holder, ParentAreaEntity<List<ParentAreaEntity>> listParentAreaEntity) {
        holder.setBinding(BR.viewModel,listParentAreaEntity);
    }


}

